# Maintainer: Peter Budai <peterbudai at hotmail.com>

# This package cannot be build with installed libgdiplus package 
# as it doesnt contain reference for GdipFontFamilyCachedGenericSansSerif

_realname=gnuplot
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=5.4.0
pkgrel=2
pkgdesc="Plotting package which outputs to X11, PostScript, PNG, GIF, and others (mingw-w64)"
arch=('any')
url='http://www.gnuplot.info/'
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-gnutls"
         "${MINGW_PACKAGE_PREFIX}-libcaca"
         "${MINGW_PACKAGE_PREFIX}-libcerf"
         "${MINGW_PACKAGE_PREFIX}-libgd"
         "${MINGW_PACKAGE_PREFIX}-pango"
         "${MINGW_PACKAGE_PREFIX}-readline"
         "${MINGW_PACKAGE_PREFIX}-wxWidgets")
#optdepends=("${MINGW_PACKAGE_PREFIX}-qt5")
#makedepends=("${MINGW_PACKAGE_PREFIX}-qt5")
options=('strip' 'staticlibs')
source=("https://downloads.sourceforge.net/sourceforge/${_realname}/${_realname}-${pkgver}.tar.gz"
        "01-gnuplot.patch" )
sha256sums=('eb4082f03a399fd1e9e2b380cf7a4f785e77023d8dcc7e17570c1b5570a49c47'
            'b07b4220743b47c88d67f41a542562329205d8a2cfa60b9e225ca5b71b4fab5d')


prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/01-gnuplot.patch
  autoreconf -fiv
}

build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}

  ../${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --without-lua \
      --with-caca \
      --with-qt=no \
      --with-bitmap-terminals

    make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
